﻿package  {
	
	import flash.display.MovieClip;
	import flash.text.TextField;
	import com.greensock.TweenMax;
	
	
	public class BaseAlert extends MovieClip {
		public static var instance:BaseAlert;
		
		public var txt_title:TextField;
		public var txt_info:TextField;
		public var btn:MovieClip;
		
		public var clickFunc:Function;
		
		public function BaseAlert() {
			super();
			BaseAlert.instance = this;
			// constructor code
			this.txt_title.text = "";
			this.txt_info.text = "";
			this.btn.btn_text.text = "";
			this.visible = false;
			this.clickFunc = function(){};
		}
		
		public function show():void
		{
			this.scaleX = 0;
			this.scaleY = 0;
			this.alpha = 0;
			this.visible = true;
			TweenMax.to(this,.3,{scaleX:1,scaleY:1,alpha:1,onComplete:function(){  }});
		}
		public function hide():void
		{
			TweenMax.to(this,.3,{scaleX:0,scaleY:0,alpha:0,onComplete:function(){ this.visible = false; this.scaleX = 1; this.scaleY = 1; this.alpha = 1; }});
		}
		
		public function showAlert(title:String, text:String, onClick:Function = null, show:Boolean = false):void
		{
			if(!onClick)
			{
				this.clickFunc = function()
				{
					this.hide();;
				}
			} else {
				this.clickFunc = onClick;
			}
			this.txt_title.text = title;
			this.txt_info.text = text;
			if(show)
			{
				this.show();
			}
		}
	}
	
}
